/**
 * sessionStorage工具类
 */


export function delsessionStorage(key) {
    sessionStorage.removeItem(key)
};

export function updatasessionStorage(key, item) {
    try {
        item = JSON.stringify(item)
    } catch (error) {

    }
    sessionStorage.setItem(key, item);
};

export function getsessionStorageShopInfo() {
    var shopInfo = [];
    var lastname = sessionStorage.getItem("shopInfo") ? sessionStorage.getItem("shopInfo") : [];
    try {
        shopInfo = JSON.parse(lastname)
    } catch (error) {
        shopInfo = []
    }
    return shopInfo;
};

export function savesessionStorage(key, item) {
    try {
        item = JSON.stringify(item)
    } catch (error) {
        item = JSON.stringify([])
        console.error(error)
    }
    sessionStorage.setItem(key, item);
};

export function getsessionStorage(key = 'UserInfo') {
    let val;
    try {
        val = JSON.parse(sessionStorage.getItem(key));
    } catch (error) {
        val = []
    }
    return val;

}